package cn.ecut.Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import cn.ecut.Bean.Manage;
import cn.ecut.DBConnection.OpenConnection;

public class ManageDao {
    public Manage manageLogin(String managename,String passwords){
        Manage manage=null;
        PreparedStatement pst = null;
        OpenConnection db = new OpenConnection();
        Connection conn = db.getConnection();
        String sql = "select managename,password from manages where managename= ? and password= ?";
        try{
            pst = conn.prepareStatement(sql);
            pst.setString(1,managename);
            pst.setString(2,passwords);
            ResultSet rs = pst.executeQuery();
            if (rs.next()){
                manage = new Manage();
                manage.setManagename(rs.getString("name"));
                manage.setPassword(rs.getString("password"));
            }
            rs.close();
            pst.close();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return manage;
    }
}
